#ifndef SOLUTION_H_
#define SOLUTION_H_
class Solution
{
public:
    int removeDuplicates(int A[], int n) 
	{
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
        if(n<=2)
			return n;

		int lastIdx = 0, count = 1;
		for(int i=1;i<n;i++)
		{
			if(A[i] != A[lastIdx])
			{
				lastIdx++;
				A[lastIdx]=A[i];
				count = 1;
			}
			else
			{
				if(count==1)
				{
					lastIdx++;
					A[lastIdx]=A[i];
					count = 2;
				}
			}				
		}

		return lastIdx+1;
    }
};
#endif